package stack;/*

 */

import java.util.Scanner;

/**
 * @ClassName ArrayStackDemo
 * @Author Final
 * @Project DataStructures
 */
public class ArrayStackDemo {

    public static void main(String[] args) {
        ArrayStack stack=new ArrayStack(5);
        String key="";
        boolean look=true;
        Scanner scanner=new Scanner(System.in);

        while (look){
            System.out.println("show:显示栈");
            System.out.println("exit:推出栈");
            System.out.println("pop:出栈");
            System.out.println("push:入栈");
            System.out.println("请输入你的选择");
            key=scanner.next();
            switch (key){
                case "show":
                    stack.list();
                    break;
                case "exit":
                    scanner.close();
                    look=false;
                    break;
                case "push":
                    System.out.println("请输入一个数");
                    int value=scanner.nextInt();
                    stack.push(value);
                    break;
                case "pop":
                    try {
                        int are =stack.pop();
                        System.out.printf("“出栈数据为%d",are);

                    }catch (Exception e){
                        System.out.println(e.getMessage());
                    }
                    break;
            }
            System.out.println("程序退出");
        }
    }
}
